package services.LoginDisplay;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import controllers.item.LoginDisplay;
import core.dao.Dao;
import core.dao.LoginDisplayService;
import entities.account.AccountEntity;
import entities.test.TestEntity;

@Service(value = "loginDisplayServiceImpl")
public class LoginDisplayServiceImpl implements LoginDisplayService {

//	@Resource(name = "dao")
//	private Dao<TestEntity> dao;
	@Resource(name = "dao")
	private Dao<AccountEntity> dao;

	/**
	 * 查询登录者并对LoginDisplay初始化
	 */
	@Override
	public LoginDisplay getLogin(String nickName, String passWord)
			throws Exception {
//		List<TestEntity> list = dao.select(TestEntity.class,
//				"select x from TestEntity as x where x.id= 1");
//		for (TestEntity test : list) {
//			System.out.println(test.getNumberTestInteger());
//			System.out.println(test.getNumberTest());
//
//		}
		 List<AccountEntity> aeL = dao.select(AccountEntity.class,
		 "from AccountEntity where nickName='" + nickName
		 + "' and passWord='" + passWord + "'");
		 if (aeL != null && aeL.size() == 1) {
		 LoginDisplay ld = new LoginDisplay(aeL.get(0).getId());
//		 ld.set(aeL.get(0));
		 return ld;
		 }
		return null;
	}
}
